import cv2

# 读取图像
img = cv2.imread('photo4.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

# 创建SIFT对象
sift = cv2.SIFT_create()

# 检测关键点并计算描述符
kp, des = sift.detectAndCompute(gray, None)

# 在图像上绘制关键点
img = cv2.drawKeypoints(gray, kp, img)

# 显示结果
cv2.imshow('SIFT Features', img)
cv2.waitKey(0)
cv2.destroyAllWindows()